package huq.com.common;

import java.util.Random;

/**
 * Configuration
 * 		some static parameters and methods
 * @author Qian
 *
 */
public class Conf {
	public static double RC_EPS = 1.0e-6;	// Tolerance
	public static int seed = 3;
	public static Random rnd = new Random(seed);
	
	public static String nextString(){
		String string = new String();
		int L = 4+rnd.nextInt(16);
		for(int i=0;i<L;i++){
			string+=nextChar();
		}
		return string;
	}
	
	public static char nextChar(){
		return (char)('A'+rnd.nextInt(26));
	}
	
	public static boolean isInteger(double d){
		/**
		 * to check whether the float number if equal to an integer
		 */
		int i=(int) Math.round(d);
		if(Math.abs(d-i) <= Conf.RC_EPS){
			return true;
		}
		else	return false;
	}
	
	public static int toInteger(double d){
		int i=(int)Math.round(d);
		if(Math.abs(d-i)<=Conf.RC_EPS){
			return i;
		}
		else{
			System.out.println("Not an Integer!");
			return (int)d;
		}
	}
}
